package com.jd.action;

import java.io.PrintWriter;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;


import org.apache.struts2.ServletActionContext;

import com.jd.po.User;
import com.jd.service.UserService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class GetGroupByAjaxAction extends ActionSupport {
	private String username;
	private UserService userService;
	
	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public String execute() throws Exception {
		User user = new User();
		User queryUser;
		String groups = null;
		user.setUsername(getUsername());
		HttpServletResponse response = ServletActionContext.getResponse();
		Map session = ActionContext.getContext().getSession();
		if((groups = userService.getGroups(user))==null) {
			return null;
		}
		PrintWriter out=response.getWriter();
		System.out.println(groups);
		out.print(groups);
		out.flush();
		return null;
		
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getUsername() {
		return username;
	}


}
